<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<header th:replace="admin/header::header-fragment">
    <link rel="stylesheet" th:href="@{mall/css/common.css}">
    <link rel="stylesheet" th:href="@{mall/styles/login.css}">
    <link rel="stylesheet" th:href="@{mall/styles/header.css}">
    <link rel="stylesheet" th:href="@{/admin/plugins/sweetalert/sweetalert.css}"/>
</header>
<style>
    .ui-jqgrid tr.jqgrow td {
        white-space: normal !important;
        height: auto;
        vertical-align: text-top;
        padding-top: 2px;
    }
</style>
<style>
    .form .login .login_center {
        width: 360px;
        margin: 10px auto;
        padding: 30px 0;
    }
</style>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
    <!-- 引入页面头header-fragment -->
    <div th:replace="admin/header::header-nav"></div>
    <!-- 引入工具栏sidebar-fragment -->
    <div th:replace="admin/sidebar::sidebar-fragment(${path})"></div>
    <!-- Content Wrapper. Contains 图标content -->
    <div class="content-wrapper">
        <!-- Content Header (图标header) -->
        <div class="content-header">
            <div class="container-fluid">
            </div><!-- /.container-fluid -->
        </div>
        <!-- Main content -->
        <div class="content">
            <div class="container-fluid">
                <div class="card card-primary card-outline">
                    <div class="card-header">
                        <h3 class="card-title">会员管理</h3>
                    </div> <!-- /.card-body -->
                    <div class="card-body">
                        <div class="grid-btn">
                            <button class="btn btn-info" onclick="lockUser(0)"><i
                                    class="fa fa-plus"></i>&nbsp;解除禁用
                            </button>
                            <button class="btn btn-danger" onclick="lockUser(1)"><i
                                    class="fa fa-trash-o"></i>&nbsp;禁用账户
                            </button>
                            <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">添加账号</button>
                        </div>
                        <div class="card-body">
                            <table id="jqGrid" class="table table-bordered">
                            </table>
                            <div id="jqGridPager"></div>
                        </div><!-- /.card-body -->
                    </div>
                </div><!-- /.container-fluid -->
            </div>
        </div>
        <!-- 模态框（Modal） -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">添加会员账号</h4>
                    </div>

                    <!--<div class="modal-body">在这里添加一些文本</div>-->
                    <div class="modal-footer">
                        <div class="login_center">
                            <form id="registerForm" onsubmit="return false;" action="##">
                                <div class="login_main center">
                                    <div class="login-info">手机号:&nbsp;<input class="login-info-input" type="text" name="loginName"
                                                                             placeholder="请输入你的手机号" id="loginName"/>
                                    </div>
                                    <div class="login-info">密&nbsp;&nbsp;&nbsp;&nbsp;码:&nbsp;<input class="login-info-input"
                                                                                                    type="password"
                                                                                                    name="password"
                                                                                                    id="password"
                                                                                                    placeholder="请输入你的密码"/>
                                    </div>
                                    <div class="login-info">最少下单量:&nbsp;<input class="login-info-input" type="text" name="leastSales"
                                                                             placeholder="请输入订单包含商品量" id="leastSales"/>
                                    </div>
                                    <div class="login-info">
                                        验证码:&nbsp;
                                        <input class="login-info-input verify-code" type="text" name="verifyCode" id="verifyCode"
                                               placeholder="请输入验证码"/>
                                        <img alt="单击图片刷新！" style="top: 14px;position: relative;" th:src="@{/common/mall/kaptcha}"
                                             onclick="this.src='/common/mall/kaptcha?d='+new Date()*1">
                                    </div>
                                </div>
                                <div class="login_submit">
                                    <input class="submit" type="button" onclick="register()" value="立即注册">
                                </div>
                            </form>
                        </div>

                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal -->
        </div>
    </div>
        <!-- /.content-wrapper -->
        <!-- 引入页脚footer-fragment -->
        <div th:replace="admin/footer::footer-fragment"></div>
    </div>
    <!-- jQuery -->
    <script th:src="@{/admin/plugins/jquery/jquery.min.js}"></script>
    <!-- jQuery UI 1.11.4 -->
    <script th:src="@{/admin/plugins/jQueryUI/jquery-ui.min.js}"></script>
    <!-- Bootstrap 4 -->
    <script th:src="@{/admin/plugins/bootstrap/js/bootstrap.bundle.min.js}"></script>
    <!-- AdminLTE App -->
    <script th:src="@{/admin/dist/js/adminlte.min.js}"></script>
    <!-- jqgrid -->
    <script th:src="@{/admin/plugins/jqgrid-5.3.0/jquery.jqGrid.min.js}"></script>
    <script th:src="@{/admin/plugins/jqgrid-5.3.0/grid.locale-cn.js}"></script>
    <!-- sweetalert -->
    <script th:src="@{/admin/plugins/sweetalert/sweetalert.min.js}"></script>
    <script th:src="@{/admin/dist/js/public.js}"></script>
    <script th:src="@{/admin/dist/js/newbee_mall_user.js}"></script>
    <script>
        function carouselAdd() {
            reset();
            $('.modal-title').html('会员添加');
            $('#userAddModal').modal('show');
        }
    </script>
    <script>
        //注册按钮onclick事件改为register()即可
        function register() {
            var loginName = $("#loginName").val();
            if (!validPhoneNumber(loginName)) {
                swal('请输入正确的登录名(即手机号)', {
                    icon: "error",
                });
                return false;
            }
            var password = $("#password").val();
            if (!validPassword(password)) {
                swal('请输入正确的密码格式(6-20位字符和数字组合)', {
                    icon: "error",
                });
                return false;
            }
            var leastSales = $("#leastSales").val();
            if (leastSales == '') {
                swal('请输入最少下单量', {
                    icon: "error",
                });
                return false;
            }
            var verifyCode = $("#verifyCode").val();
            if (!validLength(verifyCode, 7)) {
                swal('请输入正确的验证码', {
                    icon: "error",
                });
                return false;
            }
            //验证
            var params = $("#registerForm").serialize();
            var url = '/register';
            $.ajax({
                type: 'POST',//方法类型
                url: url,
                data: params,
                success: function (result) {
                    if (result.resultCode == 200) {
                        swal({
                            title: "注册成功",
                            icon: "success",
                        });
                        reload();
                    } else {
                        swal(result.message, {
                            icon: "error",
                        });
                    }
                    ;
                },
                error: function () {
                    swal("操作失败", {
                        icon: "error",
                    });
                }
            });
        }
    </script>
</body>
</html>
